#include <cppcms/application.h>
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <cppcms/http_request.h>
#include <cppcms/url_mapper.h>
#include <iostream>
#include <cppcms/http_context.h>
#include "usbtest.cpp"

using namespace std;

class hello : public cppcms::application {
public:
    hello(cppcms::service &srv) :
        cppcms::application(srv)
    {
        
    }
    virtual void main(std::string url);
    void start(std::string writebuf);
};

void hello::main(std::string /*url*/)
{
    response().content_type("application/json; charset=utf-8");
    response().out() << R"({"message":"HELLO WORLD!!!"})";

    // std::string u=request().param("id");
    // std::cout << u << endl;
    string input= request().get("input");
    
    char bb[256];
    input.copy(bb,5,0);
    tomain(bb);

}


int main(int argc,char ** argv)
{

    try {
        cppcms::service srv(argc,argv);

        srv.applications_pool().mount(
          cppcms::applications_factory<hello>()
        );
        srv.run();
    }
    catch(std::exception const &e) {
        std::cerr << e.what() << std::endl;
    }
    
}

